#ifndef __FISH_CONFIG_H__
#define __FISH_CONFIG_H__

#include <vector>
#include "../tinyxml/tinyxml.h"
#include "cocos2d.h"
namespace fishingjoy
{
	namespace config
	{
		struct SFishData
		{
			int FID;
			int AniID;
			int NormalSpeed;
			int AccSpeed;
			int AccTime;
			int RotateSpeed;
			int Percent;
			int Mark;
			int HP;
			std::string DyingSound;
		};
		class CFishConfig
		{
			static std::vector<SFishData> m_vecFishData;
			static void load()
			{
				if(m_vecFishData.size()==0){
					TiXmlDocument doc;
					std::string pathKey = "config/fishs.xml"; 
					pathKey = cocos2d::CCFileUtils::sharedFileUtils()->fullPathForFilename(pathKey.c_str());	

					if(doc.LoadFile(pathKey.c_str())){
						TiXmlElement* root = doc.RootElement();
						if(root){
							TiXmlElement* pFishNode = root->FirstChildElement();
							while(pFishNode){
								m_vecFishData.push_back(SFishData());
								SFishData& fd = m_vecFishData[m_vecFishData.size()-1];
								fd.FID = atoi(pFishNode->Attribute("fid"));
								fd.AniID = atoi(pFishNode->Attribute("ani_id"));
								fd.NormalSpeed = atoi(pFishNode->Attribute("normal_speed"));
								fd.AccSpeed = atoi(pFishNode->Attribute("acc_speed"));
								fd.AccTime = atoi(pFishNode->Attribute("acc_time"));
								fd.RotateSpeed = atoi(pFishNode->Attribute("rotate_speed"));
								fd.Percent = atoi(pFishNode->Attribute("percent"));
								fd.Mark = atoi(pFishNode->Attribute("mark"));
								fd.HP = atoi(pFishNode->Attribute("hp"));
								fd.DyingSound = pFishNode->Attribute("dying_sound");
								pFishNode = pFishNode->NextSiblingElement();
							}
						}
					}
				}
			}
		public:
			static const std::vector<SFishData>& getFishData()
			{
				load();
				return m_vecFishData;
			}
		};
	}
}

#endif